home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / src / fig16_25.jar / Ch16 / Fig16_25 / Fig16_25.cpp
C/C++ Source or Header  |  1997-11-10  |  495b  |  21 lines

  1. // Fig. 16.25: fig16_25.cpp
  2. // Using strtol
  3. #include <iostream.h>
  4. #include <stdlib.h>
  5.  
  6. int main()
  7. {
  8.    long x;
  9.    char *string = "-1234567abc", *remainderPtr;
  10.  
  11.    x = strtol( string, &remainderPtr, 0 );
  12.    cout << "The original string is \"" << string
  13.         << "\"\nThe converted value is " << x
  14.         << "\nThe remainder of the original string is \""
  15.         << remainderPtr
  16.         << "\"\nThe converted value plus 567 is " 
  17.         << x + 567 << endl;
  18.    return 0;
  19. }
  20.  
  21.